; (function (win) {
    var el;
    win.valid = function (option) {
        // console.log(option.el)
        el = document.getElementById(option.el)
        for (var item in option.rules) {
            var reg = option.rules[item].reg,
                message = option.rules[item].message,
                value = el[item].value,
                messageTag = option.rules[item].messageTag
            if (reg.test(value) == false) {
                var tag = document.getElementById(messageTag)
                if (tag) {
                    tag.innerHTML = message
                }
                console.log(messageTag)
                return
            }else{
                alert('输入正确')
                el[item].value=''
            }
        }
    }
})(window);